﻿//-------------------------------------------------------------------------------------------
// <copyright file="Dto.cs" company="Russell Wilkins">
//     Copyright (c) Russell Wilkins 2014. All Rights Reserved.
// </copyright>
// <author>Russell Wilkins</author>
// <license href="license.txt">
//     The use of this software is governed by the Microsoft Public License
//     which is included with this distribution.
// </license>
//-------------------------------------------------------------------------------------------
namespace Ripple.Providers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public class AccountData
    {
        public string Account;
        public string Balance;
        public UInt32 Flags;
        public string Index;
        public string LedgerEntryType;
        public int OwnerCount;
        public string PreviousTxnID;
        public int PreviousTxnLgrSeq;
        public int Sequence;
    }

    public class AccountInfoResult : Result
    {
        public AccountData account_data;
        public int ledger_current_index;
        public bool validated;
    }

    public class AccountInfoResultHeader
    {
        public AccountInfoResult Result;
    }

    public class AccountLineData
    {
        public string account;
        public string balance;
        public string currency;
        public string limit;
        public string limit_peer;
        public bool no_ripple;
        public bool no_ripple_peer;
        public uint quality_in;
        public uint quality_out;
    }

    public class AccountLinesResult : Result
    {
        public string account;
        public AccountLineData[] lines;
        public object marker;
    }

    public class AccountLinesResultHeader
    {
        public AccountLinesResult Result;
    }

    public class AccountOfferData
    {
        public uint flags;
        public uint seq;
        public object taker_gets;
        public object taker_pays;
    }

    public class AccountOffersResult : Result
    {
        public string account;
        public object marker;
        public AccountOfferData[] offers;
    }

    public class AccountOffersResultHeader
    {
        public AccountOffersResult Result;
    }

    public class AccountTransactionsResult : Result
    {
        public string account;
        public int ledger_index_max;
        public int ledger_index_min;
        public int limit;
        public object marker;
        public int offset;
        public TransactionData[] transactions;
        public bool validated;
    }

    public class AccountTransactionsResultHeader
    {
        public AccountTransactionsResult Result;
    }

    public class Amount
    {
        public string currency;
        public string issuer;
        public string value;
    }

    public class PingResult : Result
    {
    }

    public class PingResultHeader
    {
        public PingResult Result;
    }

    public class RandomResult : Result
    {
        public string Random;
    }

    public class RandomResultHeader
    {
        public RandomResult Result;
    }

    public class Request
    {
        public List<object> @params;
        public string method;

        public Request(string method)
        {
            this.method = method;
            this.@params = new List<object>();
        }

        public Request(string method, params object[] parameters)
        {
            this.method = method;
            this.@params = parameters.ToList();
        }
    }

    public class Result
    {
        public string Error;

        public int Error_Code;
        public string Error_Message;
        public string Status;

        public bool Success
        {
            get
            {
                return string.Compare("success", this.Status, true) == 0;
            }
        }
    }

    public class ServerInfo
    {
        public string build_version;
        public string complete_ledgers;
        public string hostid;
        public int io_latency_ms;
        public int peers;
        public string pubkey_node;
        public string server_state;
    }

    public class ServerInfoResult : Result
    {
        public ServerInfo Info;
    }

    public class ServerInfoResultHeader
    {
        public ServerInfoResult Result;
    }

    public class ServerState
    {
        public string build_version;
        public string complete_ledgers;
        public int io_latency_ms;
        public int peers;
        public string pubkey_node;
        public string server_state;
    }

    public class ServerStateResult : Result
    {
        public ServerState State;
    }

    public class ServerStateResultHeader
    {
        public ServerStateResult Result;
    }

    public class TransactionData
    {
        public int ledger_index;
        public object meta;
        public TxData tx;
        public bool validated;
    }

    public class TxData
    {
        #region Common

        public string Account;
        public object Amount;
        public double Date;
        public string Fee;
        public UInt32 Flags;
        public string Hash;
        public int ledger_index;
        public UInt32 Sequence;
        public string SigningPubKey;
        public string TransactionType;
        public string TxnSignature;

        #endregion Common

        #region TrustSet

        public Amount LimitAmount;

        #endregion TrustSet

        #region Payment

        public string Destination;

        #endregion Payment
    }
}